package com.ems.controller.supers.questions;

import com.ems.pojo.data.RequestData;
import com.ems.pojo.data.ResultData;
import com.ems.pojo.data.RetunResult;
import com.ems.pojo.data.ReturnPageResult;
import com.ems.pojo.questions.FillBanks;
import com.ems.pojo.questions.Subject;
import com.ems.service.supers.questions.FillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Auther: 伟伟
 * @Date: 2019/10/29
 * @Description: 填空题
 * @Version: 1.0
 */
@Controller
@CrossOrigin //允许所有请求跨域
@RequestMapping("/fillController")
public class FillController {

    @Autowired
    @Qualifier("fillService")
    private FillService fillService;

    /**
     * 添加填空题
     * @return
     */
    @ResponseBody
    @RequestMapping("/addFill")
    public ResultData addFill(@RequestBody List<FillBanks> fillBanksList){
        fillService.addFill(fillBanksList);
        return RetunResult.AssemblyData();
    }

    /**
     * 删除填空题
     * @param list
     * @return
     */
    @ResponseBody
    @RequestMapping("/deleteFill")
    public ResultData deleteFill(@RequestBody List<FillBanks> list){
        fillService.deleteFill(list);
        return RetunResult.AssemblyData();
    }

    /**
     * 修改填空题
     * @param fillBanks
     * @return
     */
    @ResponseBody
    @RequestMapping("/updateFill")
    public ResultData updateFill(@RequestBody FillBanks fillBanks){
        fillService.updateFill(fillBanks);
        return RetunResult.AssemblyData();
    }


    /**
     * 查询填空题
     * @param requestData
     * @return
     */
    @ResponseBody
    @RequestMapping("/findFill")
    public ResultData findFill(@RequestBody RequestData requestData){
        ReturnPageResult.setPageHelperInfo(requestData);
        List<Subject> list = fillService.findFill(requestData);
        return ReturnPageResult.AssemblyData(list);
    }

}
